package ws.very.util.dingtalk.api

import com.dingtalk.open.client.ServiceFactory
import com.dingtalk.open.client.api.service.corp.CallBackService
import collection.JavaConversions._
import scala.concurrent.{ExecutionContext, Future}

private[dingtalk] object CallBackServiceHelper {
  lazy private val callbackService = ServiceFactory.getInstance.getOpenService(classOf[CallBackService])

  //(@ParamAttr(location = Location.URL,paramKey = "access_token") String var1, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "call_back_tag") List<String> var2, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "token") String var3, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "aes_key") String var4, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "url") String var5)
  def registerCallBack(accessToken: S, callBackTag: Seq[S], token: S, aesKey: S, url: S)
                      (implicit executor: ExecutionContext) = Future {
    callbackService.registerCallBack(accessToken, callBackTag, token, aesKey, url)
  }


  //(@ParamAttr(location = Location.URL,paramKey = "access_token") String var1, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "call_back_tag") List<String> var2, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "token") String var3, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "aes_key") String var4, @ParamAttr(location = Location.JSON_CONTENT,paramKey = "url") String var5)
  def updateCallBack(accessToken: S, callBackTag: Seq[S], token: S, aesKey: S, url: S)
                    (implicit executor: ExecutionContext) = Future {
    callbackService.updateCallBack(accessToken, callBackTag, token, aesKey, url)
  }

  def deleteCallBack(accessToken: S)
                    (implicit executor: ExecutionContext) = Future {
    callbackService.deleteCallBack(accessToken)
  }

}
